<?php
function GetConnection()
{
        $con = mysql_connect('localhost', 'n02447784', 'heidi225');
        if(!$con)
        {
                throw new Exception($con->error, 1);
        }
        return $con;
}
function EscapeRow($row, $con)
{
        $arr = array();
        for($i=0;$i<count($row);$i++)
		{
				$value = $row[$i];
                $arr[$i] = mysql_real_escape_string($value, $con);
        }
        return $arr;    
}
function curl_get($path, $method="GET", $data=null)
        {
                $curl = curl_init();
                curl_setopt($curl, CURLOPT_HEADER, FALSE);
                curl_setopt($curl, CURLOPT_TIMEOUT, 20);
                curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
                curl_setopt($curl, CURLOPT_HTTPHEADER, array('Expect:'));
                curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
                curl_setopt($curl, CURLOPT_USERAGENT, 'SUNY New Paltz web course');
                if ($method === 'POST') {
                        curl_setopt($curl, CURLOPT_POST, TRUE);
                        curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
                }elseif(!empty($data)){
                        if(strpos($path, '?') === false)
                                $path .= '?';
                        else
                                $path .= '&';
                        $path .= http_build_query($data);
                }
                //echo $path;
                curl_setopt($curl, CURLOPT_URL, $path);

                return curl_exec($curl);
        }
?>
